import { get } from 'lodash-es'
import { Name } from '@/api/name/types'
import { HMemberType } from '@/api/hmember-type/types'

export class HMemberCard {
  id?: string
  hotel_id?: string
  name_id?: string
  uid?: string
  member_number?: string
  limit?: number
  begin_date?: string
  end_date?: string
  card_type?: 'Virtual' | 'Physical'
  hmember_type_id?: string
  hmember_type?: HMemberType
  consumption_count?: number
  status?: string
  status_desc?: string
  check_number?: string
  saler_id?: string
  payment_method_id?: string
  amount?: number
  reference?: string
  created_id?: string
  updated_id?: string
  created_at?: string
  updated_at?: string
  name?: Name
  version?: number;
  [key: string]: any

  constructor(data?: HMemberCard) {
    this.init(data)
  }
}

HMemberCard.prototype.init = function init(data?: HMemberCard) {
  this.id = get(data, 'id')
  this.hotel_id = get(data, 'hotel_id')
  this.name_id = get(data, 'name_id')
  this.uid = get(data, 'uid')
  this.member_number = get(data, 'member_number')
  this.limit = get(data, 'limit')
  this.begin_date = get(data, 'begin_date')
  this.end_date = get(data, 'end_date')
  this.card_type = get(data, 'card_type', 'Virtual')
  this.hmember_type_id = get(data, 'hmember_type_id')
  this.hmember_type = get(data, 'hmember_type')
  this.consumption_count = get(data, 'consumption_count')
  this.status = get(data, 'status')
  this.status_desc = get(data, 'status_desc')
  this.check_number = get(data, 'check_number')
  this.saler_id = get(data, 'saler_id')
  this.payment_method_id = get(data, 'payment_method_id')
  this.amount = get(data, 'amount')
  this.reference = get(data, 'reference')
  this.created_id = get(data, 'created_id')
  this.updated_id = get(data, 'updated_id')
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_id')
  this.version = get(data, 'version')
  this.name = get(data, 'name')
}

export type DashboardTongji = {
  inhouse: number
  today_total: number
  today_member: number
  member_total: number
}
